<?php
session_start();
?>

<html>
<head>

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="pupdate.js"></script>
<script type="text/javascript">
window.onload = function(){
	//document.getElementById('generatedTable').innerHTML = '';
}
var generateTable = function()
{
	var sRaw = <?php echo $_POST['orderList'] ?> || '';
	var	sItem = sRaw.split(','); //get D01=1 D02=2
	for(var i = 0; i < sItem.length; i++)
	{
		
	}
}
</script>
</head>

<body bgcolor="#FFFFFF">
<?php      

include("../../MerchandiseBay/conn.php");
/*
		$arr = $_POST['id'];
		$arr2 = $_POST['quantity'];
		$i = 1;
		foreach ($arr as $value) {
		$value2 = $arr2[$i];
		 $SQL1="select * from merchandise where id='".$value."'";
		 $qry1=mysql_query($SQL1,$conn);
		 while($row1=mysql_fetch_array($qry1))
	    { 
		extract($row1);
		 $SQL2="insert into reservation(name,telno,email,reservationdate,reservationtime,codeproduct,quantity,category,kind,address,status) values ('".$_SESSION['username']."','".$_REQUEST[telno]."','".$_REQUEST[email]."','".$_REQUEST[reservationdate]."','".$_REQUEST[time]."','".$value."','".$value2."','".$category."','".$kind."','".$_REQUEST[location]."','non')";
		 $qry2=mysql_query($SQL2,$conn);
		 }
		 $i = $i + 1 ;
		}
*/

  $username=$_SESSION['username'];
  $SQL="select * from users where username='".$_SESSION['username']."'";
  //$SQL="select * from users where username='$username'";
  $qry=mysql_query($SQL,$conn);

  while($row=mysql_fetch_array($qry))
	    { 
		  extract($row);  
?>

<form name="reservation" method="post" action="confirmReservation.php">
  <table width="74%" height="387" border="0" cellpadding="0" cellspacing="0">
    <tr> 
      <td height="33" colspan="2"><font color="#0000FF" size="5" face="Times New Roman, Times, serif"><strong>User Information </strong></font></td>
    </tr>
    <tr> 
      <td width="36%" height="32"><div align="right"><font color="#000000"><strong>Name 
          * :</strong></font></div></td>
      <td width="64%"><?php echo $firstname; ?></td>
    </tr>
    <tr> 
      <td height="35"><div align="right"><font color="#000000"><strong>Tel No 
          * :</strong></font></div></td>
      <td><?php echo $telno; ?></td>
    </tr>
    <tr> 
      <td height="32"><div align="right"><font color="#000000"><strong>Email * 
          :</strong></font></div></td>
      <td><?php echo $email; ?></td>
    </tr>
    <tr> 
      <td height="82"><div align="right"> 
          <p><font color="#000000"><strong>Location * :</strong></font></p>
          <p>&nbsp;</p>
        </div></td>
      <td><p> 
         <?php echo $location;?>
		  
        </p></td>
    </tr>
    <tr> 
      <td height="23" colspan="2"><p><font face="Times New Roman, Times, serif"><strong><font color="#0000FF" size="5">Reservation 
          Information</font></strong></font></p>
        <p>&nbsp;</p></td>
    </tr>
    <tr> 
      <td height="22"><div align="right"><font color="#000000"><strong>Reservation 
          Date :</strong></font></div></td>
      <td><font face="Verdana"> 
        <input name="reservationdate" type="text" value="<?  echo $_REQUEST[reservationdate]; ?>">
        </font></td>
    </tr>
   <!-- <tr> 
      <td height="24"> <div align="right"><font color="#FF6600"><font color="#000000"></font></font></div></td>
      <td><font face="Verdana"> 
        <input type="button" value="choose one.." name="button1" onClick="getCalendarFor(document.reservation.reservationdate)">
        </font></td>
    </tr>-->
    <tr>
      <td height="31" align="right"><p><strong>Time :</strong></p></td>
      <td><font face="Verdana">
        <input name="reservationtime" type="text" value="<?  echo $_REQUEST[time]; ?>">
		<!--<input name="id" type="text" value="<?   $box = $_POST['quantity'];while (list ($key,$val) = @each ($box)) { 
echo "$val,"; 
} ?>">
		<input name="quantity" type="text" value="<?  echo $_REQUEST[location]; ?>">-->
		
      </font></td>
    </tr>
	<tr> 
      <td height="23" colspan="2"><p><font face="Times New Roman, Times, serif"><strong><font color="#0000FF" size="5">Your Selected Menu </font></strong></font></p>
        <p>&nbsp;</p></td>
    </tr>
    <tr>
    <td><strong>Item</strong></td>
    <td><strong>Quantity</strong></td>
    </tr>
	<?
	/*$SQL3="select * from reservation where name='".$_SESSION['username']."' and reservationdate='".$_REQUEST[reservationdate]."' and reservationtime='".$_REQUEST[time]."'";
	$qry3=mysql_query($SQL3,$conn);
	while($row3=mysql_fetch_array($qry3))
	{ 
	extract($row3);*/
	function getName($sCode, $conn)
	{
		$sql = 'select kind from merchandise where regno = "'.$sCode.'"';

		$result=mysql_query($sql,$conn);
		while($result=mysql_fetch_assoc($result))
		{
			return $result['kind'];
		}
		
	}
	$List = split(',', $_REQUEST['orderList']);
	//$List[0] === 'X01=3'

	for($counter = 0; $counter < count($List); $counter+=1)
	{
		$item = split('=',$List[$counter]);
		//$item[0] === 'X01'
		//$item[1] === '3'
	?>
		<tr><td><?php echo getName($item[0], $conn); ?></td><td><?php echo $item[1]; ?></td></tr>
	<?php } ?>


	<?
	}
	
	?>
    <tr> 
      <td height="32"><div align="right">
        <p>&nbsp;</p>
        <p><font color="#FF6600"><strong>
        <input type="hidden" name="orderList" value="<?php echo $_POST['orderList']; ?>"/>
          <input type="submit" name="Submit" value="Submit">
        </strong></font></p>
      </div></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"> <div align="left"></div></td>
    </tr>
  </table>
</form>
  	<?php
	
//}	

	?>
<p>&nbsp;<!-- PopUp Calendar BEGIN -->
<script language="JavaScript">
if (document.all) {
 document.writeln("<div id=\"PopUpCalendar\" style=\"position:absolute; left:0px; top:0px; z-index:7; width:200px; height:77px; overflow: visible; visibility: hidden; background-color: #FFFFFF; border: 1px none #000000\" onMouseOver=\"if(ppcTI){clearTimeout(ppcTI);ppcTI=false;}\" onMouseOut=\"ppcTI=setTimeout(\'hideCalendar()\',500)\">");
 document.writeln("<div id=\"monthSelector\" style=\"position:absolute; left:0px; top:0px; z-index:9; width:181px; height:27px; overflow: visible; visibility:inherit\">");}
else if (document.layers) {
 document.writeln("<layer id=\"PopUpCalendar\" pagex=\"0\" pagey=\"0\" width=\"200\" height=\"200\" z-index=\"100\" visibility=\"hide\" bgcolor=\"#FFFFFF\" onMouseOver=\"if(ppcTI){clearTimeout(ppcTI);ppcTI=false;}\" onMouseOut=\"ppcTI=setTimeout('hideCalendar()',500)\">");
 document.writeln("<layer id=\"monthSelector\" left=\"0\" top=\"0\" width=\"181\" height=\"27\" z-index=\"9\" visibility=\"inherit\">");}
else {
 document.writeln("<p><font color=\"#FF0000\"><b>Error ! The current browser is either too old or too modern (usind DOM document structure).</b></font></p>");}
</script>
<noscript><p><font color="#FF0000"><b>JavaScript is not activated !</b></font></p></noscript>
<table border="1" cellspacing="1" cellpadding="2" width="200" bordercolorlight="#000000" bordercolordark="#000000" vspace="0" hspace="0"><form name="ppcMonthList"><tr><td align="center" bgcolor="#CCCCCC"><a href="javascript:moveMonth('Back')" onMouseOver="window.status=' ';return true;"><font face="Arial, Helvetica, sans-serif" size="2" color="#000000"><b>&lt;&nbsp;</b></font></a><font face="MS Sans Serif, sans-serif" size="1"> <font color="#434343"></font>
<select name="sItem" onMouseOut="if(ppcIE){window.event.cancelBubble = true;}" onChange="switchMonth(this.options[this.selectedIndex].value)" style="font-family: 'MS Sans Serif', sans-serif; font-size: 9pt"><option value="0" selected>2000 &#149; January</option><option value="1">2000 &#149; February</option><option value="2">2000 &#149; March</option><option value="3">2000 &#149; April</option><option value="4">2000 &#149; May</option><option value="5">2000 &#149; June</option><option value="6">2000 &#149; July</option><option value="7">2000 &#149; August</option><option value="8">2000 &#149; September</option><option value="9">2000 &#149; October</option><option value="10">2000 &#149; November</option><option value="11">2000 &#149; December</option><option value="0">2001 &#149; January</option></select></font><a href="javascript:moveMonth('Forward')" onMouseOver="window.status=' ';return true;"><font face="Arial, Helvetica, sans-serif" size="2" color="#000000"><b>&nbsp;&gt;</b></font></a></td></tr></form></table>
<table border="1" cellspacing="1" cellpadding="2" bordercolorlight="#000000" bordercolordark="#000000" width="200" vspace="0" hspace="0"><tr align="center" bgcolor="#CCCCCC"><td width="20" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, sans-serif" size="1">Su</font></b></td><td width="20"><b><font face="MS Sans Serif, sans-serif" size="1">Mo</font></b></td><td width="20"><b><font face="MS Sans Serif, sans-serif" size="1">Tu</font></b></td><td width="20"><b><font face="MS Sans Serif, sans-serif" size="1">We</font></b></td><td width="20"><b><font face="MS Sans Serif, sans-serif" size="1">Th</font></b></td><td width="20"><b><font face="MS Sans Serif, sans-serif" size="1">Fr</font></b></td><td width="20" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, sans-serif" size="1">Sa</font></b></td></tr></table>
<script language="JavaScript">
if (document.all) {
 document.writeln("</div>");
 document.writeln("<div id=\"monthDays\" style=\"position:absolute; left:0px; top:52px; z-index:8; width:200px; height:17px; overflow: visible; visibility:inherit; background-color: #FFFFFF; border: 1px none #000000\">&nbsp;</div></div>");}
else if (document.layers) {
 document.writeln("</layer>");
 document.writeln("<layer id=\"monthDays\" left=\"0\" top=\"52\" width=\"200\" height=\"17\" z-index=\"8\" bgcolor=\"#FFFFFF\" visibility=\"inherit\">&nbsp;</layer></layer>");}
else {/*NOP*/}
</script>
<!-- PopUp Calendar END --></p>
</body>
</html>
